package io.github.uicdb.et.recipe.handler;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.github.uicdb.et.ModTurnInRecipeHandlerTypes;
import io.github.uicdb.et.recipe.TurnInRecipeHandler;
import io.github.uicdb.et.recipe.TurnInRecipeHandlerType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.minecraft.world.item.ItemStack;

@RequiredArgsConstructor
@Getter
public class ToItemStackHandler extends TurnInRecipeHandler {
    final ItemStack item;

    public static final MapCodec<ToItemStackHandler> CODEC = RecordCodecBuilder.mapCodec(
            i->i.group(ItemStack.CODEC.fieldOf("item").forGetter(ToItemStackHandler::getItem)).apply(i,ToItemStackHandler::new)
    );

    @Override
    public ItemStack handleRecipe(ItemStack input) {
        return item.copy();
    }

    @Override
    protected TurnInRecipeHandlerType<?> getType() {
        return ModTurnInRecipeHandlerTypes.TO_ITEM.get();
    }
}
